package com.xiaozheng.dao;

import com.xiaozheng.daomain.Account;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

/**
 * @Package: com.xiaozheng.dao
 * @ClassName: AccountDao
 * @Author: 小政同学    QQ:xiaozheng666888@qq.com
 * @CreateTime: 2020/9/19 12:41
 * @What_is_this_file_for: 这个文件是用来做什么的?
 * @Description: 描述
 */
public interface AccountDao {
    /**
     * 查询所有用户，并且获取每个账户所属的用户信息
     * @return
     */

    @Select("select * from account")
    @Results(id = "accountMap",value = {
            @Result(id = true,column ="id",property = "id"),
            @Result(column = "uid" ,property = "uid"),
            @Result(column = "money" ,property = "money"),
            @Result(column = "uid",property = "user",one = @One(select = "com.xiaozheng.dao.UserDao.findById",fetchType = FetchType.EAGER))
    })
    List<Account> findAll();

    @Select("select * from account where uid = #{id}")
    List<Account> findById(Integer id);
}
